package com.qf.gh.web.servlet;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
@WebServlet("/bookcovers")
public class BookCovers extends BaseServlet{
   public void show(HttpServletRequest request, HttpServletResponse response)throws Exception{
    String picture = request.getParameter("picture");
    String basePath = this.getServletContext().getRealPath("WEB-INF/bookcovers");
    String path=basePath+ File.separator+picture;
    File dir=new File(path);
    if(!dir.exists()) {
//            return;
    }
    FileInputStream fis=new FileInputStream(path);
    ServletOutputStream os = response.getOutputStream();
    byte [] buf=new byte[1024*50];
    int len;
    while((len=fis.read(buf))!=-1){
        os.write(buf,0,len);
    }
}
}
